task :backup_db, :roles => [:db] do
  if prod_db && Capistrano::CLI.ui.agree('*'*80 + "\nDump production datbase (#{prod_db}) to backup.sql? [yes,no]")
    run "mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set=utf8 --user='#{backup_user}' --password='#{backup_pass}' #{prod_db} > #{release_path}/db/backup.sql"
  end
end

before 'deploy:migrate', :backup_db
